package one.stand.controller;

import com.jmp.autocofiguration.web.interceptor.SecurityAuthCheck;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import one.stand.model.ResultModel;
import one.stand.request.CompanyRoyaltyRequest;
import one.stand.request.CompanyTransferRequest;
import one.stand.request.OrdersRequest;
import one.stand.request.RoyaltyRecordRequest;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * 分销管理
 *
 * @author
 */
@RestController
@RequestMapping("crmPc/distribution")
public class DistributionController extends BaseController {

    @ApiOperation(value = "分销管理-数据统计")
    @PostMapping("/getRoyaltyData")
    @SecurityAuthCheck(company = true, card = true)
    public ResultModel<Map<String, Object>> getRoyaltyData(@RequestAttribute RoyaltyRecordRequest request) {
        return crmFegin.getRoyaltyData(request);
    }

    @ApiOperation(value = "设置分销金额比例")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "level", value = "提成等级", required = true, paramType = "Integer"),
            @ApiImplicitParam(name = "royaltyRatio", value = "提成比例", required = true, paramType = "Integer"),
    })
    @PostMapping("/companyRoyalty")
    @SecurityAuthCheck(company = true, card = true)
    public ResultModel<Boolean> companyRoyalty(@RequestAttribute CompanyRoyaltyRequest request) {
        return crmFegin.companyRoyalty(request);
    }

    @ApiOperation(value = "分销订单列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "orderState", value = "订单状态（1待付款，2待发货，3待收货，4已完成，5交易取消，6退款成功）", required = true, paramType = "Integer"),
    })
    @PostMapping("/selectRoyaltyOrderList")
    @SecurityAuthCheck(company = true, card = true)
    public ResultModel<Map<String, Object>> selectRoyaltyOrderList(@RequestAttribute OrdersRequest request) {
        return crmFegin.selectRoyaltyOrderList(request);
    }

    @ApiOperation(value = "分销订单详情")
    @PostMapping("/getRoyaltyOrderInfo")
    @SecurityAuthCheck(company = true, card = true)
    public ResultModel<Map<String, Object>> getRoyaltyOrderInfo(@RequestAttribute OrdersRequest request) {
        return crmFegin.getRoyaltyOrderInfo(request);
    }

    @ApiOperation(value = "佣金排行列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "dateType", value = "1总金额排名 2本月佣金排名 3上月佣金排名", required = true, paramType = "Integer"),
    })
    @PostMapping("/selectRoyaltyRankList")
    @SecurityAuthCheck(company = true, card = true)
    public ResultModel<Map<String, Object>> selectRoyaltyRankList(@RequestAttribute RoyaltyRecordRequest request) {
        return crmFegin.selectRoyaltyRankList(request);
    }

    @ApiOperation(value = "企业到账记录列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "state", value = "0失败1线上提现成功2线下交易", paramType = "Integer"),
    })
    @PostMapping("/selectCompanyTransferList")
    @SecurityAuthCheck(company = true, card = true)
    public ResultModel<Map<String, Object>> selectCompanyTransferList(@RequestAttribute CompanyTransferRequest request) {
        return crmFegin.selectCompanyTransferList(request);
    }

    @ApiOperation(value = "更改结算状态")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "transferId", value = "公司转账id", required = true, paramType = "Integer"),
    })
    @PostMapping("/updateCompanyTransferState")
    @SecurityAuthCheck(company = true, card = true)
    public ResultModel<Boolean> updateCompanyTransferState(@RequestAttribute CompanyTransferRequest request) {
        return crmFegin.updateCompanyTransferState(request);
    }

}
